var e = getApp(), o = e.api,
  is_loading_more = !1, is_no_more = !1;
Page({
  data: {
    flag: 0
  },
  //点击切换显示内容
  flagFun: function (e) {
    var that = this;
    var name = e.currentTarget.dataset.name;
    var id = that.data.couponid;
    var index = e.currentTarget.dataset.flagindex
    // wx.setStorageSync('status', e.currentTarget.dataset.flagindex)
    that.setData({
      flag: e.currentTarget.dataset.flagindex,
    });
    if (index==0){
      that.loadData(id)
    }else{
      that.loadData(index)
    }
    
  },
  cardBag(e) {
    console.log(111)
    var coupon_id = e.currentTarget.dataset.coupon_id;
    var user_id = e.currentTarget.dataset.user_id;
    wx.navigateTo({
      url: '/pages/cardBagc/cardBagc?user_id=' + user_id + '&coupon_id=' + coupon_id,
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  onLoad: function (o) {
 
    var that = this;
   var couponid = o.id;
    that.loadData(couponid),that.setData({
      couponid: couponid
    })
  },
  onReady: function () {
    // e.pageOnReady(this);
  },
  // onShow: function () {
  //   //e.pageOnShow(this),
  //   var status = wx.getStorageSync('status');
  //   this.loadData(status);
  // },
  loadData: function (couponid) {
    console.log(couponid,66667);
    var n = this;
    var t = getApp().getUser();
    wx.showLoading({
      title: "加载中"
    }),e.request({
        url: o.user.managecouponsend,
        method: "post",
        data: {
          couponid: couponid,
          
        },
        success: function (e) {
          console.log(1111, e);
          if (0 == e.code) {
            wx.hideLoading();
            n.setData({
              user_coupon: e.data
            })
          } else wx.showToast({
            title: "网络错误",
            image: "/images/icon-warning.png"
          });
        }
      });
  },
  coupon_qrcode: function (n) {
    var t = this, a = n.currentTarget.dataset;
    e.request({
      url: o.user.user_coupon_qrcode,
      method: "GET",
      data: {
        user_coupon_id: a.id
      },
      success: function (e) {
        0 == e.code ? t.setData({
          user_coupon_qrcode: e.data.pic_url,
          showModel: !0
        }) : wx.showToast({
          title: "网络错误",
          image: "/images/icon-warning.png"
        });
      }
    });
  },
  preventTouchMove: function () { },
  hideModal: function () {
    this.setData({
      showModel: !1
    });
  },
  onHide: function () {
    //e.pageOnHide(this);
  },
  onUnload: function () {
    // e.pageOnUnload(this);
  },
  onPullDownRefresh: function () { },
  onReachBottom: function () { },
  onShareAppMessage: function () { }
});